<?php

function call_api($data = array())
{
	$url = 'http://localhost:8080/otekoo/api/talk/';
	
	if($data instanceof GenericArray)
		$data = $data->getData();

	$options = array(
		CURLOPT_SSL_VERIFYHOST => 0,
		CURLOPT_SSL_VERIFYPEER => 0
	);

	$defaults = array(
		CURLOPT_URL => $url. (strpos($url, '?') 
		   === FALSE ? '?' : ''). http_build_query($data),
		CURLOPT_HEADER => 0,
		CURLOPT_RETURNTRANSFER => TRUE,
		CURLOPT_TIMEOUT => 400
	);

	$ch = curl_init();
	curl_setopt_array($ch, ($options + $defaults));
	if( ! $result = curl_exec($ch))
	{
		trigger_error(curl_error($ch));
	}

	curl_close($ch);
	return $result;
}
if(!empty($_REQUEST))
{
	echo call_api($_REQUEST);
	exit;
}
?>

<form>
	Name: <input type="text" name="name"><br>
	Email: <input type="text" name="email"><br>
	Message: <textarea rows="5" cols="10" name="message"></textarea><br>
	<input type="submit" value="Create">
</form>